<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系统首页</title>
<link rel="stylesheet" href="css/bootstrap-3.2.0/css/bootstrap.css"/>
<link rel="stylesheet" href="css/navigate.css"/>
<link href="js/validator/jquery.validator.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/navigate.js"></script>
<script src="js/jsviews.js"></script>
<script	type="text/javascript" src="js/validator/jquery.validator.js"></script>
<script type="text/javascript" src="js/validator/local/zh_CN.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$.ajax({
		url:'xaCmsUser/showMenu',
		type:'get',
		dataType:'json',
		success:function(data){
			console.log(data);
			var menuHtml = $("#nav_menu").render(data.currentMenuData);
			$("#userName").html(data.currentUser.userName);
			$("#myUserId").val(data.currentUser.userId);
			$("#leftNav").append(menuHtml).leftNavMenu({single: true});
		}
	});
	
	$("#userName").click(function(){
		$('#validateForm')[0].reset();
		$("#myModal").modal();
	});
	$("#myupdate").click(function(){
		$('#validateForm').isValid(function(result){
		    if(!result){
				alert("还有未填写的字段，请检查！");
				return;
		    }
		    var userId=$("#myUserId").val();
		    var newPassword=$("#newPassword").val();
		    var oldPassword=$("#oldPassword").val();
		    $.ajax({
		    	url:"xaCmsUser/update/"+userId+"/"+newPassword+"/"+oldPassword,
		    	type:'POST',
		    	dataType:'json',
		    	success:function(data){
		    		console.log(data);
		    		if(data.status==1){
		    			alert("密码修改成功");
		    			$('#myModal').modal('hide');
		    		}else{
		    			alert(data.result);
		    		}
		    	}
		    });
		});
		
	});
});
</script>
</head>
<body>
<div class="container-fluid pro-body">
	<div class="ti-header">
		<div class="logoClass"></div>
		<div align="right" class="ti-info" id="userContent">
		<input type="hidden" id="myUserId" name="myUserId" />
			<label id="userName" style="cursor: pointer;"></label><span style="font-size: 14px;color:#FFFFFF">：欢迎您回来</span>&nbsp;&nbsp;&nbsp;&nbsp;
			<br/>
			<a href="j_spring_security_logout" style="color: red;">退出</a>&nbsp;&nbsp;&nbsp;&nbsp;
		</div>
	</div>
	<div class="ti-body">
		<div id="leftNav" class="ti-nav-menu"></div>
		<div class="ti-main">
			<div id="ti_panel" class="ti-panel">
				<div class="panel-head">
					<button type="button" class="btn btn-warning btn-sm ti-return" onclick="closePanel();"><span class="glyphicon glyphicon-backward"></span>返回</button>
				</div>
				<div id="ti_panel_body" class="ti-panel-body">
					<iframe id="ti_panel_frame" class="ti-body-frame" frameborder="0" scrolling="auto"></iframe>
				</div>
			</div>
			<iframe id="ti_main_frame" class="ti-main-frame" frameborder="0" scrolling="auto"></iframe>
		</div>
	</div>
</div>
<section>
<!--菜单模板===begin===-->
<script id="nav_menu" type="text/x-jsrender">
	<div class="nav-tatle">{{:title}}</div>
	{{for items}}
	<div class="nav-line">
		<a class="nav-item"><span class="{{:icon}} nav-tbar"></span>{{:text}}<span class="glyphicon glyphicon-chevron-left nav-bar"></span></a>
		{{if list}}
		<ul>
			{{for list}}
			<li><a class="nav-secnt" href="{{:href}}">{{:text}}</a></li>
			{{/for}}
		</ul>
		{{/if}}
	</div>
	{{/for}}
</script>
<!--菜单模板====end====-->
</section>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
   <form id="validateForm">
	<div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" 
               data-dismiss="modal" aria-hidden="true">
                  &times;
            </button>
            <h4 class="modal-title" id="myModalLabel">
               修改密码
            </h4>
         </div>
         <div class="modal-body">
            <fieldset> 
				<div class="control-group">
					<label for="userPhoto2" class="control-label">旧密码：</label>
					<div class="controls">
						<input type="password" placeholder="请填写旧密码" data-rule="旧密码:required;password;" id="oldPassword" name="oldPassword" />
					</div>
				</div>
				<!-- Select Basic -->
				<div class="control-group">
					<label for="userType" class="control-label">新密码：</label>
					<div class="controls" >
						<input type="password" placeholder="请填写新密码" data-rule="新密码:required;password;" id="newPassword" name="newPassword" />
					</div>
				</div>
				<div class="control-group">
					<label for="userPassword" class="control-label">确认新密码</label>
					<div class="controls">
						<input type="password" required="required" id="newpassword1" data-rule="确认密码:required;password;match(newPassword);"  placeholder="请再次输入新密码" name="newpassword1" />
					</div>
				</div>
			</fieldset>
         </div>
         <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal">关闭
            </button>
            <button type="button" id="myupdate" class="btn btn-primary">
               确定
            </button>
         </div>
      </div>
</form>
</div>

</body>
</html>

